{extend name="public:base" /}
{block name="theme"}业务管理{/block}
{block name="small_theme"}业务列表{/block}
{block name="breadcrumb"}
<li><a href="{:url('olist')}">业务列表</a></li>
<li class="active">业务首页</li>
{/block}
{block name="content"}
<!--<link rel="stylesheet" href="__CSS__/style.css">-->

<style>
    input.error { border: 1px solid red; }
    label.error {
        font-weight: bold;
        color: #EA5200;
    }
</style>

<link rel="stylesheet" href="__CSS__/indexcommon.css">

<section class="content" style="min-height: 200px;font-size: 12px;">
    <form method="get" action="{:url('qdsendmessage')}" >
        <div class="box_">
            <div class="box_left">
                <div class="form-group">
                    <label>ID</label>
                    <input type="text" class="form-control" name="id" placeholder="ID" value="{$form.id}" >
                </div>
                <div class="form-group">
                    <label>姓名</label>
                    <input type="" class="form-control" name="name" placeholder="顾客姓名" value="{$form.name}" >
                </div>
                <div class="form-group">
                    <label>妈妈电话</label>
                    <input type="" class="form-control" name="maphone" placeholder="电话"  value="{$form.maphone}">
                </div>
                <div class="form-group">
                    <label>家人电话</label>
                    <input type="" class="form-control" name="otherphone" placeholder="电话"  value="{$form.otherphone}">
                </div>

                <div class="form-group">
                    <label>业务状态</label>
                    <select class="form-control" name="ywstate">
                        <option value="">全部</option>
                        {volist name='ywstate' id='data'}
                        <option value="{$data.id}" {eq name="form['ywstate']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>渠道</label><!-- 网络部渠道来源  或者  转介绍来源  -->
                    <select class="form-control" name="qudao">
                        <option value="">全部</option>
                        {volist name='qudao' id='data'}
                        <option value="{$data.id}" {eq name="form['qudao']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>

                <div class="form-group">
                    <label>区域</label>
                    <select class="form-control" name="area" id="area">
                        <option value="">全部</option>
                        {volist name='area' id='data'}
                        <option value="{$data.id}" {eq name="form['area']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>收集医院</label>
                    <select class="form-control" name="yiyuan" id="yiyuan">
                        <option value="">全部</option>
                        {volist name='yiyuan' id='data'}
                        <option value="{$data.id}" {eq name="form['yiyuan']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>医院渠道</label>
                    <select class="form-control" name="menzhen" id="menzhen">
                        <option value="">全部</option>
                        {volist name='menzhen' id='data'}
                        <option value="{$data.id}" {eq name="form['menzhen']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>建单部门</label>
                    <select class="form-control" name="qd_depar">
                        <option value="">全部</option>
                        {volist name='bumen' id='data'}
                        <option value="{$data.id}" {eq name="form['qd_depar']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>建单客服</label>
                    <select class="form-control" name="jdry">
                        <option value="">全部</option>
                        {volist name='jdkf' id='data'}
                        <option value="{$data.id}" {eq name="form['jdry']" value="$data.id"}selected="selected"{/eq} >{$data.username}</option>
                        {/volist}
                    </select>
                </div>


                <div class="form-group">
                    <label>反馈人员</label>
                    <select class="form-control" name="fkry">
                        <option value="">全部</option>
                        {volist name='fkry' id='data'}
                        <option value="{$data.id}" {eq name="form['fkry']" value="$data.id"}selected="selected"{/eq} >{$data.username}</option>
                        {/volist}
                    </select>
                </div>












                <div class="form-group " >
                    <label>预产期</label>
                    <input type="text" class="form-control form-time" id="yctime" name="yctime" value="{$form.yctime}"  >
                </div>
                <div class="form-group">
                    <label>建单时间</label>
                    <input type="text" class="form-control form-time" id="jdtime" name="jdtime" value="{$form.jdtime}" >
                </div>




            </div>
            <div class="box_right">
                <button class="btn btn-color-g">开始</br>查询</button>
                            <a type="reset" href="{:url('olist',['reset'=>1])}" class="btn btn-success" id="resetbtn">重置</br>表单</a>
            </div>
        </div>
    </form>
</section>
<!-- 查询结束 -->
<!-- 列表开始 -->
<div class="row" style="padding:15px;">
    <div class="col-xs-12">
        <form  id="commentForm" method="post" action="{:url('qdfssendmessage')}" class="layui-form">
        <div class="box box-list">
            <div class="box-header" data-original-title="" style="height: auto;">
                <span>
                    <label>地区&nbsp;</label>
                    <select class="form-control" name="area" style="width:10%;" id="areakc">
                        <option value="">全部</option>
                        {volist name='area' id='data'}
                        <option value="{$data.id}" {eq name="mapfasong['area']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </span>
                <span>
                    <label>医院&nbsp;</label>
                    <select class="form-control" name="yiyuan" style="width:18%;" id="yiyuankc">
                        <option value="">全部</option>
                        {volist name='yiyuan' id='data'}
                        <option value="{$data.id}" {eq name="mapfasong['yiyuan']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </span>
                <!--&nbsp;&nbsp;&nbsp;&nbsp;-->
                <span>
                    <label>课程&nbsp;</label>
                    <select class="form-control" name="kecheng" style="width: 12%;" id="kecheng">
                        <option value="">全部</option>
                        {volist name='kecheng' id='data'}
                        <option value="{$data.id}" {eq name="mapfasong['kecheng']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </span>
                <!--&nbsp;&nbsp;&nbsp;&nbsp;-->
                <span>
                    <label>上课时间&nbsp;</label>
                    <input type="text" class="form-control form-time" id="sktime" name="sktime"  onclick="laydate({min:laydate.now()})"  value="{$mapfasong.sktime}" style="width: 15%;">
                </span>
                <!--&nbsp;&nbsp;&nbsp;&nbsp;-->
                <button class="btn" type="submit" id="submit" style="background-color:rgba(0, 107, 239, 0.62);">发送短信<i class="fa  fa-envelope"></i></button>
            </div>
            <div class="box-body table-responsive no-padding" style="border-bottom: 1px solid #dfdfdf;overflow: hidden;">
                <table class="table table-striped table-bordered table-condensed">
                    <tr>
                        <th><input id="checkAll" type="checkbox" />全选</th>
                        <th>ID</th>
                        <th>姓名</th>
                        <th>妈妈电话</th>
                        <th>预产期</th>
                        <th>建单时间</th>
                        <th>区域</th>
                        <th>收集医院</th>
                        <th>医院渠道</th>
                        <!--<th>渠道</th>-->
                        <th>业务状态</th>
                        <th>建单人员</th>
                        <th>建单部门</th>
                        <th>反馈人员</th>
                        <th>转介绍人员</th>
                        <th>发送次数</th>
                    </tr>
                    {volist name='list' id="vo" }
                    <tr id="id{$vo.id}">
                        <td><input type="checkbox" name="ids[]" class="checkbox" value="{$vo.id},{$vo.maphone}"></td>
                        <!--<td><input type="checkbox" name="maphones[]" class="checkbox" value="{$vo.maphone}"></td>-->
                        <td>{$vo.id}</td>
                        <td>{$vo.name}</td>
                        <td>{$vo.maphone_text}</td>
                        {eq name="vo.yctime" value="1970-01-01"}<td></td>{else/}<td>{$vo.yctime}</td>{/eq}
                        {eq name="vo.jdtime" value="1970-01-01 8:00"}<td></td>{else/}<td>{$vo.jdtime}</td>{/eq}
                        <td>{$vo.area_text}</td>
                        <td><span class="tanchu" data-toggle="tooltip" data-placement="right" title="{$vo.yyxx_text}">{$vo.yyxx_text|msubstr=0,6}</span></td><!-- 医院信息 -->
                        <td>{$vo.menzhen_text}</td>
                        <!--<td>{$vo.qdxx_text}</td>&lt;!&ndash; 渠道信息 &ndash;&gt;-->
                        <!--<td><span class="color{$vo.ywstate}">{$vo.state_text}</span></td>&lt;!&ndash; 业务状态 &ndash;&gt;-->
                        <td><span style="background-color: {$vo.color_text};width: 80px;">{$vo.state_text}</span></td>
                        <td>{$vo.jdry_text}</td> <!-- 建单人员 -->
                        <td>{$vo.bumen_text}</td>
                        <td>{$vo.fkry_text}</td> <!-- 反馈人员 -->
                        <td>{$vo.zjsry_text}</td> <!-- 转介绍人员 -->
                        <td><span class="label bg-red">{$vo.qdyytkplmsg}</span></td>
                    </tr>
                    {/volist}

                </table>

            </div>
            <div class="page">{$page}</div>
        </div>
        </form>
    </div>
</div>
<!-- 列表结束 -->
</div>
{/block}

{block name="js"}
<script type="text/javascript" src="__JS__/date.js"></script>
<script type="text/javascript" src="__JS__/yewu.js"></script>
<script type="text/javascript" src="__STATIC__/laydate/laydate.js"></script>
<script type="text/javascript" src="__STATIC__/validate/jquery.validate.min.js"></script>


<script type="text/javascript">
    document.onselectstart = function(){
        event.returnValue = false;
    }


    $(function() {
        $("#checkAll").click(function(){
//            $('.checkbox').attr("checked",this.checked);
            $(".checkbox").click();
        });
        var yiyuan = $('#yiyuan option:selected').val();
        if(yiyuan > 0){
            $('#yiyuankc').empty();
            $("<option value=''>"+'请选择医院'+"</optinon>").appendTo( $('#yiyuankc') );
            $.post("/admin/yewu/getYiyuan", {area:$('#area').val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"' >"+n.name+"</optinon>").appendTo( $('#yiyuankc') );
                    });
                    $("#yiyuankc").val(yiyuan);
                }
            });
            $('#kecheng').empty();
            $("<option value=''>"+'请选择医院课程'+"</optinon>").appendTo( $('#kecheng') );
            $.post("/admin/kcgl/getKecheng", {yiyuan:yiyuan},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.name+"</optinon>").appendTo( $('#kecheng') );
                    });
                }
            });
        }
        $('#areakc').change(function () {
            $('#yiyuankc').empty();
            $('#kecheng').empty();
            $("<option value=''>"+'请选择医院'+"</optinon>").appendTo( $('#yiyuankc') );
            $("<option value=''>"+'请选择医院课程'+"</optinon>").appendTo( $('#kecheng') );
            $.post("/admin/yewu/getYiyuan", {area:$('#areakc').val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.name+"</optinon>").appendTo( $('#yiyuankc') );
                    });
                }
            });
        });

        $('#yiyuankc').change(function () {
            $('#kecheng').empty();
            $("<option value=''>"+'请选择医院课程'+"</optinon>").appendTo( $('#kecheng') );
            $.post("/admin/kcgl/getKecheng", {yiyuan:$('#yiyuankc').val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.name+"</optinon>").appendTo( $('#kecheng') );
                    });
                }
            });
        });

        $('#yiyuan').change(function () {
            var yiyuan = $('#yiyuan').val();
            $('#yiyuankc').empty();
            $("<option value=''>"+'请选择医院'+"</optinon>").appendTo( $('#yiyuankc') );
            $.post("/admin/yewu/getYiyuan", {area:$('#area').val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"' >"+n.name+"</optinon>").appendTo( $('#yiyuankc') );
                    });
                    $("#yiyuankc").val(yiyuan);
                }
            });

            $('#kecheng').empty();
            $("<option value=''>"+'请选择医院课程'+"</optinon>").appendTo( $('#kecheng') );
            $.post("/admin/kcgl/getKecheng", {yiyuan:yiyuan},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.name+"</optinon>").appendTo( $('#kecheng') );
                    });
                }
            });
        });

    });


    $().ready(function() {
        // 在键盘按下并释放及提交后验证提交表单
        $("#commentForm").validate({

            rules: {
                yiyuan: { required : true},
                kecheng:{ required : true},
                sktime: { required : true,date : true},
            },
            messages: {
                yiyuan: "请选择医院",
                kecheng:"请选择课程",
                sktime:	{ required:"请选择日期", date:"日期格式不对" },
            },

            submitHandler: function(form)
            {
                $.ajax({
                    type: "POST",
                    url:  "{:url('qdfssendmessage')}",
                    data: $('#commentForm').serialize(),
                    beforeSend:function(){
                        $('#submit').attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
//                        console.log(msg);

                        if(msg.status==0){
                            layer.msg(msg.msg, {icon: msg.icon});
                            $('#submit').removeAttr("disabled"); //可以点击
                        }else{
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.msg, {icon: msg.icon});
                            setTimeout(function(){
                                location.reload();
                            },3000); //延迟演示
                        }

                    }
                });
            }

        });
        return false;
    });

    highlight_subnav("{:url('qdsendmessage')}");

</script>
{/block}
